home *** CD-ROM | disk | FTP | other *** search
- Subject: v20i037: Troff upgrade for PostScript, DiTroff compatibility, Part05/06
- Newsgroups: comp.sources.unix
- Sender: sources
- Approved: rsalz@uunet.UU.NET
-
- Submitted-by: Chris Lewis <eci386!clewis@uunet.uu.net>
- Posting-number: Volume 20, Issue 37
- Archive-name: psroff/part05
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 5 (of 6)."
- # Contents: dt.c ps.c
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'dt.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'dt.c'\"
- else
- echo shar: Extracting \"'dt.c'\" \(16363 characters\)
- sed "s/^X//" >'dt.c' <<'END_OF_FILE'
- X/* Copyright 1985, 1986, 1987, 1988 Chris Lewis
- X All Rights Reserved
- X
- X Permission to copy and further distribute is freely given provided
- X this copyright notice remains intact and that this software is not
- X sold for profit.
- X
- X Project: Generic Troff drivers
- X Module: dt.c
- X Author: Chris Lewis
- X Specs: Ditroff driver
- X */
- X
- X#include "defs.h"
- X
- X#ifdef DT
- X#include "dt.h"
- X
- Xint currentPage = 0;
- X
- X#ifndef SVR3
- X#ifndef lint
- Xstatic char SCCSid[] = "@(#)dt.c: 1.5 Copyright 89/07/04 16:59:46 Chris Lewis";
- X#endif
- X#else
- X#ident "@(#)dt.c: 1.5 Copyright 89/07/04 16:59:46 Chris Lewis" /*(SVR3)*/
- X#endif
- X
- X#define MAXFONT 50
- X
- X#define USED 01
- X
- Xstruct dtFts {
- X char *troffName;
- X char *ascName;
- X int flags;
- X} dtFts[MAXFONT+1];
- X
- Xstruct dtFts *t2dtf[8];
- X
- Xstruct troff2befont dtStdFont[108] = {
- X
- X/* +-------------------------------- Troff character number
- X |
- X | +--------------------------- U: standard fonts
- X | | S: symbol font
- X | | D: draw macro
- X | | n: new font
- X | |
- X | | +------------------------ X-shift (scaled by point)
- X | | | Note: positive is right.
- X | | |
- X | | | +--------------------- Y-shift (scaled by point)
- X | | | | Note: positive is up.
- X | | | |
- X | | | | +------------------ Point scale factor
- X | | | | |
- X | | | | | +-------------- Sequence
- X | | | | | |
- X | | | | | | Printable sequence title
- X | | | | | | |
- X | | | | | | |
- X v v v v v v v */
- X /* 1*/ {U, 0, 0, 1, "h", "h"},
- X /* 2*/ {U, 0, 0, 1, "t", "t"},
- X /* 3*/ {U, 0, 0, 1, "n", "n"},
- X /* 4*/ {U, 0, 0, 1, "m", "m"},
- X /* 5*/ {U, 0, 0, 1, "l", "l"},
- X /* 6*/ {U, 0, 0, 1, "i", "i"},
- X /* 7*/ {U, 0, 0, 1, "z", "z"},
- X /* 8*/ {U, 0, 0, 1, "s", "s"},
- X /* 9*/ {U, 0, 0, 1, "d", "d"},
- X /* 10*/ {U, 0, 0, 1, "b", "b"},
- X /* 11*/ {U, 0, 0, 1, "x", "x"},
- X /* 12*/ {U, 0, 0, 1, "f", "f"},
- X /* 13*/ {U, 0, 0, 1, "j", "j"},
- X /* 14*/ {U, 0, 0, 1, "u", "u"},
- X /* 15*/ {U, 0, 0, 1, "k", "k"},
- X /* 16*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /* 17*/ {U, 0, 0, 1, "p", "p"},
- X /* 18*/ {U, 0, 0, 1, "em", "3/4 em"},
- X /* 19*/ {U, 0, 0, 1, ";", ";"},
- X /* 20*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /* 21*/ {U, 0, 0, 1, "a", "a"},
- X /* 22*/ {U, 0, 0, 1, "ru", "horizontal rule"},
- X /* 23*/ {U, 0, 0, 1, "c", "c"},
- X /* 24*/ {U, 0, 0, 1, "`", "` open"},
- X /* 25*/ {U, 0, 0, 1, "e", "e"},
- X /* 26*/ {U, 0, 0, 1, "'", "' close"},
- X /* 27*/ {U, 0, 0, 1, "o", "o"},
- X /* 28*/ {U, 0, 0, 1, "14", "1/4"},
- X /* 29*/ {U, 0, 0, 1, "r", "r"},
- X /* 30*/ {U, 0, 0, 1, "12", "1/2"},
- X /* 31*/ {U, 0, 0, 1, "v", "v"},
- X /* 32*/ {U, 0, 0, 1, "hy", "- hyphen"},
- X /* 33*/ {U, 0, 0, 1, "w", "w"},
- X /* 34*/ {U, 0, 0, 1, "q", "q"},
- X /* 35*/ {U, 0, 0, 1, "/", "/"},
- X /* 36*/ {U, 0, 0, 1, ".", "."},
- X /* 37*/ {U, 0, 0, 1, "g", "g"},
- X /* 38*/ {U, 0, 0, 1, "34", "3/4"},
- X /* 39*/ {U, 0, 0, 1, ",", ","},
- X /* 40*/ {U, 0, 0, 1, "&", "&"},
- X /* 41*/ {U, 0, 0, 1, "y", "y"},
- X /* 42*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /* 43*/ {U, 0, 0, 1, "%", "%"},
- X /* 44*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /* 45*/ {U, 0, 0, 1, "Q", "Q"},
- X /* 46*/ {U, 0, 0, 1, "T", "T"},
- X /* 47*/ {U, 0, 0, 1, "O", "O"},
- X /* 48*/ {U, 0, 0, 1, "H", "H"},
- X /* 49*/ {U, 0, 0, 1, "N", "N"},
- X /* 50*/ {U, 0, 0, 1, "M", "M"},
- X /* 51*/ {U, 0, 0, 1, "L", "L"},
- X /* 52*/ {U, 0, 0, 1, "R", "R"},
- X /* 53*/ {U, 0, 0, 1, "G", "G"},
- X /* 54*/ {U, 0, 0, 1, "I", "I"},
- X /* 55*/ {U, 0, 0, 1, "P", "P"},
- X /* 56*/ {U, 0, 0, 1, "C", "C"},
- X /* 57*/ {U, 0, 0, 1, "V", "V"},
- X /* 58*/ {U, 0, 0, 1, "E", "E"},
- X /* 59*/ {U, 0, 0, 1, "Z", "Z"},
- X /* 60*/ {U, 0, 0, 1, "D", "D"},
- X /* 61*/ {U, 0, 0, 1, "B", "B"},
- X /* 62*/ {U, 0, 0, 1, "S", "S"},
- X /* 63*/ {U, 0, 0, 1, "Y", "Y"},
- X /*from here on are actually code 1-45, upper half of font */
- X /* 64*/ {U, 0, 0, 1, "F", "F"},
- X /* 65*/ {U, 0, 0, 1, "X", "X"},
- X /* 66*/ {U, 0, 0, 1, "A", "A"},
- X /* 67*/ {U, 0, 0, 1, "W", "W"},
- X /* 68*/ {U, 0, 0, 1, "J", "J"},
- X /* 69*/ {U, 0, 0, 1, "U", "U"},
- X /* 70*/ {U, 0, 0, 1, "K", "K"},
- X /* 71*/ {U, 0, 0, 1, "0", "0"},
- X /* 72*/ {U, 0, 0, 1, "1", "1"},
- X /* 73*/ {U, 0, 0, 1, "2", "2"},
- X /* 74*/ {U, 0, 0, 1, "3", "3"},
- X /* 75*/ {U, 0, 0, 1, "4", "4"},
- X /* 76*/ {U, 0, 0, 1, "5", "5"},
- X /* 77*/ {U, 0, 0, 1, "6", "6"},
- X /* 78*/ {U, 0, 0, 1, "7", "7"},
- X /* 79*/ {U, 0, 0, 1, "8", "8"},
- X /* 80*/ {U, 0, 0, 1, "9", "9"},
- X /* 81*/ {U, 0, 0, 1, "*", "*"},
- X /* 82*/ {U, 0, 0, 1, "-", "minus"},
- X /* 83*/ {U, 0, 0, 1, "fi", "fi"},
- X /* 84*/ {U, 0, 0, 1, "fl", "fl"},
- X /* 85*/ {U, 0, 0, 1, "ff", "ff"},
- X /* 86*/ {U, 0, 0, 1, "ct", "cent sign"},
- X /* 87*/ {U, 0, 0, 1, "Fl", "ffl"},
- X /* 88*/ {U, 0, 0, 1, "Fi", "ffi"},
- X /* 89*/ {U, 0, 0, 1, "(", "("},
- X /* 90*/ {U, 0, 0, 1, ")", ")"},
- X /* 91*/ {U, 0, 0, 1, "[", "["},
- X /* 92*/ {U, 0, 0, 1, "]", "]"},
- X /* 93*/ {U, 0, 0, 1, "de", "degree"},
- X /* 94*/ {U, 0, 0, 1, "dg", "dagger"},
- X /* 95*/ {U, 0, 0, 1, "=", "="},
- X /* 96*/ {U, 0, 0, 1, "rg", "registered"},
- X /* 97*/ {U, 0, 0, 1, ":", ":"},
- X /* 98*/ {U, 0, 0, 1, "+", "+"},
- X /* 99*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /*100*/ {U, 0, 0, 1, "!", "!"},
- X /*101*/ {U, 0, 0, 1, "bu", "bullet"},
- X /*102*/ {U, 0, 0, 1, "?", "?"},
- X /*103*/ {U, 0, 0, 1, "fm", "foot mark (minute)"},
- X /*104*/ {U, 0, 0, 1, "|", "|"},
- X /*105*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /*106*/ {U, 0, 0, 1, "co", "copyright"},
- X /*107*/ {U, 0, 0, 1, "sq", "square"},
- X /*108*/ {U, 0, 0, 1, "$", "$"}
- X};
- X
- Xstruct troff2befont dtSymFont[] = {
- X/* +-------------------------------- Troff character number
- X |
- X | +--------------------------- U: standard fonts
- X | | S: symbol font
- X | | D: draw macro
- X | |
- X | | +------------------------ X-shift (scaled by point)
- X | | | Note: positive is right.
- X | | |
- X | | | +--------------------- Y-shift (scaled by point)
- X | | | | Note: positive is up.
- X | | | |
- X | | | | +------------------ Point scale factor
- X | | | | |
- X | | | | | +-------------- Sequence
- X | | | | | |
- X | | | | | | Printable sequence title
- X | | | | | | |
- X | | | | | | |
- X v v v v v v v */
- X /* 1*/ {S, 0, 0, 1, "*q", "psi"},
- X /* 2*/ {S, 0, 0, 1, "*h", "theta"},
- X /* 3*/ {S, 0, 0, 1, "*n", "nu"},
- X /* 4*/ {S, 0, 0, 1, "*m", "mu"},
- X /* 5*/ {S, 0, 0, 1, "*l", "lambda"},
- X /* 6*/ {S, 0, 0, 1, "*i", "iota"},
- X /* 7*/ {S, 0, 0, 1, "*z", "zeta"},
- X /* 8*/ {S, 0, 0, 1, "*s", "sigma"},
- X /* 9*/ {S, 0, 0, 1, "*d", "delta"},
- X /* 10*/ {S, 0, 0, 1, "*b", "beta"},
- X /* 11*/ {S, 0, 0, 1, "*c", "xi"},
- X /* 12*/ {S, 0, 0, 1, "*y", "eta"},
- X /* 13*/ {S, 0, 0, 1, "*f", "phi"},
- X /* 14*/ {S, 0, 0, 1, "*u", "upsilon"},
- X /* 15*/ {S, 0, 0, 1, "*k", "kappa"},
- X /* 16*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /* 17*/ {S, 0, 0, 1, "*p", "pi"},
- X /* 18*/ {S, 0, 0, 1, "@", "@"},
- X /* 19*/ {S, 0, 0, 1, "da", "down arrow"},
- X /* 20*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /* 21*/ {S, 0, 0, 1, "*a", "alpha"},
- X /* 22*/ {S, 0, 0, 1, "or", "or (was star)"},
- X /* 23*/ {S, 0, 0, 1, "*x", "chi"},
- X /* 24*/ {U, 0, 0, 1, "\"", "double quote"},
- X /* 25*/ {S, 0, 0, 1, "*e", "epsilon"},
- X /* 26*/ {S, 0, 0, 1, "eq", "equation equal"},
- X /* 27*/ {S, 0, 0, 1, "*o", "omicron"},
- X /* 28*/ {S, 0, 0, 1, "<-", "left arrow"},
- X /* 29*/ {S, 0, 0, 1, "*r", "rho"},
- X /* 30*/ {S, 0, 0, 1, "ua", "up arrow"},
- X /* 31*/ {S, 0, 0, 1, "*t", "tau"},
- X /* 32*/ {S, 0, 0, 1, "ul", "underline"},
- X /* 33*/ {U, 0, 0, 1, "\\", "back slash"},
- X /* 34*/ {S, 0, 0, 1, "*Q", "Psi"},
- X /* 35*/ {S, 0, 0, 1, "?", "bell system sign"},
- X /* 36*/ {S, 0, 0, 1, "if", "infinity"},
- X /* 37*/ {S, 0, 0, 1, "*g", "gamma"},
- X /* 38*/ {S, 0, 0, 1, "ip", "improper superset"},
- X /* 39*/ {S, 0, 0, 1, "pt", "proportional to"},
- X /* 40*/ {S, 0, 0, 1, "rh", "right hand"},
- X /* 41*/ {S, 0, 0, 1, "*w", "omega"},
- X /* 42*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /* 43*/ {S, 0, 0, 1, "gr", "gradient"},
- X /* 44*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /* 45*/ {S, 0, 0, 1, "*F", "Phi"},
- X /* 46*/ {S, 0, 0, 1, "*H", "Theta"},
- X /* 47*/ {S, 0, 0, 1, "*W", "Omega"},
- X /* 48*/ {S, 0, 0, 1, "cu", "union"},
- X /* 49*/ {S, 0, 0, 1, "rn", "root en"},
- X /* 50*/ {S, 0, 0, 1, "ts", "terminal sigma (was root em)"},
- X /* 51*/ {S, 0, 0, 1, "*L", "Lambda"},
- X /* 52*/ {S, 0, 0, 1, "mi", "equation minus"},
- X /* 53*/ {S, 0, 0, 1, "*G", "Gamma"},
- X /* 54*/ {S, 0, 0, 1, "is", "integral sign"},
- X /* 55*/ {S, 0, 0, 1, "*P", "Pi"},
- X /* 56*/ {S, 0, 0, 1, "sb", "subset of"},
- X /* 57*/ {S, 0, 0, 1, "sp", "superset of"},
- X /* 58*/ {S, 0, 0, 1, "ap", "approximates"},
- X /* 59*/ {S, 0, 0, 1, "pd", "partial derivative"},
- X /* 60*/ {S, 0, 0, 1, "*D", "Delta"},
- X /* 61*/ {S, 0, 0, 1, "sr", "square root"},
- X /* 62*/ {S, 0, 0, 1, "*S", "Sigma"},
- X /* 63*/ {S, 0, 0, 1, "~=", "approx ="},
- X /* 64*/ {S, 0, 0, 1, ">", ">"},
- X /* 65*/ {S, 0, 0, 1, "*C", "Xi"},
- X /* 66*/ {S, 0, 0, 1, "<", "<"},
- X /* 67*/ {S, 0, 0, 1, "/", "slash"},
- X /* 68*/ {S, 0, 0, 1, "ca", "intersect"},
- X /* 69*/ {S, 0, 0, 1, "*U", "Upsilon"},
- X /* 70*/ {S, 0, 0, 1, "no", "logical not"},
- X /* 71*/ {S, 0, 0, 1, "rc", "right ceiling"},
- X /* 72*/ {S, 0, 0, 1, "lt", "left top brace"},
- X /* 73*/ {S, 0, 0, 1, "bv", "bold vertical"},
- X /* 74*/ {S, 0, 0, 1, "lk", "left ctr brace"},
- X /* 75*/ {S, 0, 0, 1, "lb", "left bot brace"},
- X /* 76*/ {S, 0, 0, 1, "rt", "right top brace"},
- X /* 77*/ {S, 0, 0, 1, "rk", "right ctr brace"},
- X /* 78*/ {S, 0, 0, 1, "rb", "right bot brace"},
- X /* 79*/ {S, 0, 0, 1, "rf", "right floor"},
- X /* 80*/ {S, 0, 0, 1, "lf", "left floor"},
- X /* 81*/ {S, 0, 0, 1, "lc", "left ceiling"},
- X /* 82*/ {S, 0, 0, 1, "mu", "multiply"},
- X /* 83*/ {S, 0, 0, 1, "di", "divide"},
- X /* 84*/ {S, 0, 0, 1, "+-", "plus-minus"},
- X /* 85*/ {S, 0, 0, 1, "<=", "<="},
- X /* 86*/ {S, 0, 0, 1, ">=", ">="},
- X /* 87*/ {S, 0, 0, 1, "==", "identically equal"},
- X /* 88*/ {S, 0, 0, 1, "!=", "not equal"},
- X /* 89*/ {S, 0, 0, 1, "{", "{"},
- X /* 90*/ {S, 0, 0, 1, "}", "}"},
- X /* 91*/ {U, 0, 0, 1, "aa", "acute accent"},
- X /* 92*/ {U, 0, 0, 1, "ga", "grave accent"},
- X /* 93*/ {S, 0, 0, 1, "^", "^"},
- X /* 94*/ {S, 0, 0, 1, "#", "#"},
- X /* 95*/ {S, 0, 0, 1, "lh", "left hand"},
- X /* 96*/ {S, 0, 0, 1, "mo", "member of"},
- X /* 97*/ {U, 0, 0, 1, "~", "~"},
- X /* 98*/ {S, 0, 0, 1, "es", "empty set"},
- X /* 99*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /*100*/ {U, 0, 0, 1, "dd", "dbl dagger"},
- X /*101*/ {S, 0, 0, 1, "br", "box rule (was parallel sign)"},
- X /*102*/ {S, 0, 0, 1, "**", "math * "},
- X /*103*/ {S, 0, 0, 1, "ib", "improper subset"},
- X /*104*/ {S, 0, 0, 1, "ci", "circle"},
- X /*105*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /*106*/ {S, 0, 0, 1, "pl", "equation plus"},
- X /*107*/ {S, 0, 0, 1, "->", "right arrow"},
- X /*108*/ {U, 0, 0, 1, "sc", "section"}
- X};
- X
- XdtPage() {
- X pagePending = 1;
- X}
- X
- Xstatic
- XdoPageStart(e) {
- X currentPage++;
- X pagePending = 0;
- X printf("p%d\n", currentPage);
- X}
- X
- Xstatic int lastFont = (-1), lastPoints = (-1);
- X
- XdtSetFont(font, points)
- Xint font, points; {
- X if (lastPoints != points || font != lastFont) {
- X if (!(dtFts[font].flags)&USED)
- X printf("x font %d %s\n", font+1, dtFts[font].troffName);
- X dtFts[font].flags |= USED;
- X printf("f%d\n", font+1);
- X printf("s%d\n", points);
- X lastPoints = points;
- X lastFont = font;
- X }
- X}
- X
- XdtChar(x, y, font, points, troffChar)
- Xint x, y, font, points, troffChar; {
- X static double lasty = (-1);
- X register double nx = TROFF2DTX(x), ny = TROFF2DTY(y);
- X register struct troff2befont *rp;
- X register char *sequence = "a";
- X if (pagePending) {
- X lasty = lastFont = lastPoints = (-1);
- X doPageStart();
- X }
- X
- X DEBUGPRINTF("x,y=%d,%d; font=%d, points=%d, tc=%d\n",
- X x, y, font, points, troffChar);
- X
- X if (font == 3) {
- X rp = &be->besymfont[troffChar];
- X } else {
- X rp = &be->bestdfont[troffChar];
- X }
- X
- X switch(rp->t2b_font) {
- X /* Only fonts with "U" are subject to font translation */
- X case U:
- X if (font == 3)
- X font = 0; /* Special chars are Courier */
- X else {
- X DEBUGPRINTF("dtSetChar %d->%s (%s)\n", font,
- X t2dtf[font]->troffName,
- X t2dtf[font]->ascName);
- X font = t2dtf[font] - dtFts;
- X }
- X break;
- X case S:
- X font = 3;
- X break;
- X case D:
- X break;
- X default:
- X /* Typically used when the main fonts don't have the
- X character desired. Eg: right-hand is in the
- X ZapfDingbats font */
- X font = rp->t2b_font;
- X break;
- X }
- X
- X sequence = rp->t2b_charseq;
- X
- X if (!sequence) {
- X fprintf(stderr, "No coding for %d\n", troffChar);
- X return;
- X }
- X
- X /* We're committed now */
- X
- X points *= rp->t2b_scale;
- X nx += points * rp->t2b_xc;
- X ny += points * rp->t2b_yc;
- X dtSetFont(font, points);
- X#ifdef NOTYET
- X if (rp->t2b_font == D)
- X printf("H%d\nV%d\nc%s\n", (int) nx, (int) ny, sequence);
- X else {
- X#endif
- X printf("H%d\n", (int) nx);
- X if (lasty != ny) {
- X printf("V%d\n", (int) ny);
- X lasty = ny;
- X }
- X if (sequence[1])
- X printf("C%s\n", sequence);
- X else
- X printf("c%s\n", sequence);
- X#ifdef NOTYET
- X }
- X#endif
- X}
- X
- XdtProlog() {
- X extern char *getlogin(), *ctime();
- X extern char *strchr();
- X extern char nodename[];
- X extern char *device;
- X char buf2[512];
- X char buffer[512];
- X FILE *library;
- X int c;
- X long curtime;
- X
- X currentPage = 0;
- X pagePending = 1;
- X
- X for (c = 0; c < 8; c++)
- X t2dtf[c] = &dtFts[c];
- X
- X sprintf(buf2, "%s.%s", DTFONTS, be->bename);
- X
- X if ((library = fopen(buf2, "r")) == NULL) {
- X sprintf(buffer, "%s/%s", LIBDIR, buf2);
- X if ((library = fopen(buffer, "r")) == NULL) {
- X fprintf(stderr, "Cannot open PostScript font definitions %s\n",
- X buffer);
- X exit(1);
- X }
- X }
- X
- X loadfontdefs(library);
- X fclose(library);
- X
- X time(&curtime);
- X strcpy(buffer, ctime(&curtime));
- X *strchr(buffer, '\n') = '\0';
- X
- X getnodename();
- X
- X printf("#Title: (stdin)\n");
- X printf("#Creator: %s %s %s\n", getlogin(), progname, T2VERSION);
- X printf("#CreationDate: %s\n", buffer);
- X printf("#For: %s\n", getlogin());
- X printf("#Pages: (atend)\n");
- X printf("#DocumentFonts: (atend)\n");
- X printf("#EndComments\n");
- X printf("x T %s\n", device);
- X printf("x res %d %d %d\n", DTRESOLUTION, 1, 1);
- X printf("x init\n");
- X
- X}
- X
- XdtEpilog() {
- X printf("x trailer\n");
- X printf("x stop\n");
- X}
- X
- XdtFontSel(from, to)
- Xchar from, *to; {
- X#ifdef DEBUG
- X register int i;
- X register struct dtFts *p;
- X#endif
- X DEBUGPRINTF("dtFontSel: %c -> %s\n", from, to);
- X if (from < '1' || from > '8') {
- X fprintf(stderr, "Bad arguments to dtFontSel: %c %s\n", from, to);
- X return;
- X }
- X
- X for (p = dtFts; p->troffName; p++)
- X if (strcmp(p->troffName, to) == 0) {
- X t2dtf[from - '1'] = p;
- X break;
- X }
- X if (!p->troffName) {
- X fprintf(stderr, "Could not translate font %c (%s)\n", from, to);
- X }
- X#ifdef DEBUG
- X for (i = 0; i < 8; i++)
- X DEBUGPRINTF("Font %d->%s\n", i+1, t2dtf[i]->ascName);
- X#endif
- X}
- X
- X/*struct troff2befont *
- XdtGetFontTables(which)
- Xint which; {
- X return(which? symbolFont: standardFont);
- X}*/
- X
- Xstatic
- Xloadfontdefs(f)
- XFILE *f; {
- X struct dtFts *p = dtFts;
- X extern char *malloc();
- X int flags;
- X char rbuf[512], nbuf[512], dtbuf[512];
- X while(fgets(rbuf, sizeof(rbuf), f)) {
- X if (rbuf[0] == '#')
- X continue;
- X switch(sscanf(rbuf, "%s%s", nbuf, dtbuf)) {
- X default:
- X break;
- X case 2:
- X if (nbuf[0] == '#')
- X break;
- X if (p - dtFts >= MAXFONT) {
- X fprintf(stderr, "Too many font definitions in %s\n",
- X be->bename);
- X exit(1);
- X }
- X p->troffName = malloc(strlen(nbuf) + 1);
- X strcpy(p->troffName, nbuf);
- X p->ascName = malloc(strlen(dtbuf) + 1);
- X strcpy(p->ascName, dtbuf);
- X p->flags = 0;
- X p++;
- X }
- X }
- X#ifdef DEBUG
- X for (p = dtFts; p->troffName; p++)
- X DEBUGPRINTF("%s -> %s\n", p->troffName, p->ascName);
- X#endif
- X}
- X#endif /* DT */
- END_OF_FILE
- if test 16363 -ne `wc -c <'dt.c'`; then
- echo shar: \"'dt.c'\" unpacked with wrong size!
- fi
- # end of 'dt.c'
- fi
- if test -f 'ps.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ps.c'\"
- else
- echo shar: Extracting \"'ps.c'\" \(19066 characters\)
- sed "s/^X//" >'ps.c' <<'END_OF_FILE'
- X/* Copyright 1985, 1986, 1987, 1988 Chris Lewis
- X All Rights Reserved
- X
- X Permission to copy and further distribute is freely given provided
- X this copyright notice remains intact and that this software is not
- X sold for profit.
- X
- X Project: Generic Troff drivers
- X Module: ps.c
- X Author: Chris Lewis
- X Specs: PostScript driver
- X */
- X
- X#include "defs.h"
- X
- X#ifdef PS
- X#include "ps.h"
- X
- X#ifndef SVR3
- X#ifndef lint
- Xstatic char SCCSid[] = "@(#)ps.c: 1.24 Copyright 89/08/28 17:11:47 Chris Lewis";
- X#endif
- X#else
- X#ident "@(#)ps.c: 1.24 Copyright 89/08/28 17:11:47 Chris Lewis" /*(SVR3)*/
- X#endif
- X
- X#define METRICS
- Xstatic charCount;
- X
- X#ifdef FORM
- Xstatic char Overlay[100] = {""};
- X#endif
- X
- X#ifdef BIN
- Xstatic char Bin = 'D';
- X#endif
- X
- X#define MAXFONT 50
- X
- X#define USED 01
- X
- Xstruct psFts {
- X char *troffName;
- X char *fontName;
- X int flags;
- X} psFts[MAXFONT+1];
- X
- Xstruct psFts *t2psf[8];
- X
- Xstruct troff2befont psStdFont[108] = {
- X
- X/* +-------------------------------- Troff character number
- X |
- X | +--------------------------- U: standard fonts
- X | | S: symbol font
- X | | D: draw macro
- X | | n: new font
- X | |
- X | | +------------------------ X-shift (scaled by point)
- X | | | Note: positive is right.
- X | | |
- X | | | +--------------------- Y-shift (scaled by point)
- X | | | | Note: positive is up.
- X | | | |
- X | | | | +------------------ Point scale factor
- X | | | | |
- X | | | | | +-------------- Sequence
- X | | | | | |
- X | | | | | | Printable sequence title
- X | | | | | | |
- X | | | | | | |
- X v v v v v v v */
- X /* 1*/ {U, 0, 0, 1, "h", "h"},
- X /* 2*/ {U, 0, 0, 1, "t", "t"},
- X /* 3*/ {U, 0, 0, 1, "n", "n"},
- X /* 4*/ {U, 0, 0, 1, "m", "m"},
- X /* 5*/ {U, 0, 0, 1, "l", "l"},
- X /* 6*/ {U, 0, 0, 1, "i", "i"},
- X /* 7*/ {U, 0, 0, 1, "z", "z"},
- X /* 8*/ {U, 0, 0, 1, "s", "s"},
- X /* 9*/ {U, 0, 0, 1, "d", "d"},
- X /* 10*/ {U, 0, 0, 1, "b", "b"},
- X /* 11*/ {U, 0, 0, 1, "x", "x"},
- X /* 12*/ {U, 0, 0, 1, "f", "f"},
- X /* 13*/ {U, 0, 0, 1, "j", "j"},
- X /* 14*/ {U, 0, 0, 1, "u", "u"},
- X /* 15*/ {U, 0, 0, 1, "k", "k"},
- X /* 16*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /* 17*/ {U, 0, 0, 1, "p", "p"},
- X /* 18*/ {D, 0, 0, 1, "do34em", "3/4 em"},
- X /* 19*/ {U, 0, 0, 1, ";", ";"},
- X /* 20*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /* 21*/ {U, 0, 0, 1, "a", "a"},
- X /* 22*/ {D, 0, 0, 1, "doru", "horizontal rule"},
- X /* 23*/ {U, 0, 0, 1, "c", "c"},
- X /* 24*/ {U, 0, 0, 1, "`", "` open"},
- X /* 25*/ {U, 0, 0, 1, "e", "e"},
- X /* 26*/ {U, 0, 0, 1, "'", "' close"},
- X /* 27*/ {U, 0, 0, 1, "o", "o"},
- X /* 28*/ {D, 0, 0, 1, "do14", "1/4"},
- X /* 29*/ {U, 0, 0, 1, "r", "r"},
- X /* 30*/ {D, 0, 0, 1, "do12", "1/2"},
- X /* 31*/ {U, 0, 0, 1, "v", "v"},
- X /* 32*/ {U, 0, 0, 1, "-", "- hyphen"},
- X /* 33*/ {U, 0, 0, 1, "w", "w"},
- X /* 34*/ {U, 0, 0, 1, "q", "q"},
- X /* 35*/ {U, 0, 0, 1, "/", "/"},
- X /* 36*/ {U, 0, 0, 1, ".", "."},
- X /* 37*/ {U, 0, 0, 1, "g", "g"},
- X /* 38*/ {D, 0, 0, 1, "do34", "3/4"},
- X /* 39*/ {U, 0, 0, 1, ",", ","},
- X /* 40*/ {U, 0, 0, 1, "&", "&"},
- X /* 41*/ {U, 0, 0, 1, "y", "y"},
- X /* 42*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /* 43*/ {U, 0, 0, 1, "\%", "%"},
- X /* 44*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /* 45*/ {U, 0, 0, 1, "Q", "Q"},
- X /* 46*/ {U, 0, 0, 1, "T", "T"},
- X /* 47*/ {U, 0, 0, 1, "O", "O"},
- X /* 48*/ {U, 0, 0, 1, "H", "H"},
- X /* 49*/ {U, 0, 0, 1, "N", "N"},
- X /* 50*/ {U, 0, 0, 1, "M", "M"},
- X /* 51*/ {U, 0, 0, 1, "L", "L"},
- X /* 52*/ {U, 0, 0, 1, "R", "R"},
- X /* 53*/ {U, 0, 0, 1, "G", "G"},
- X /* 54*/ {U, 0, 0, 1, "I", "I"},
- X /* 55*/ {U, 0, 0, 1, "P", "P"},
- X /* 56*/ {U, 0, 0, 1, "C", "C"},
- X /* 57*/ {U, 0, 0, 1, "V", "V"},
- X /* 58*/ {U, 0, 0, 1, "E", "E"},
- X /* 59*/ {U, 0, 0, 1, "Z", "Z"},
- X /* 60*/ {U, 0, 0, 1, "D", "D"},
- X /* 61*/ {U, 0, 0, 1, "B", "B"},
- X /* 62*/ {U, 0, 0, 1, "S", "S"},
- X /* 63*/ {U, 0, 0, 1, "Y", "Y"},
- X /*from here on are actually code 1-45, upper half of font */
- X /* 64*/ {U, 0, 0, 1, "F", "F"},
- X /* 65*/ {U, 0, 0, 1, "X", "X"},
- X /* 66*/ {U, 0, 0, 1, "A", "A"},
- X /* 67*/ {U, 0, 0, 1, "W", "W"},
- X /* 68*/ {U, 0, 0, 1, "J", "J"},
- X /* 69*/ {U, 0, 0, 1, "U", "U"},
- X /* 70*/ {U, 0, 0, 1, "K", "K"},
- X /* 71*/ {U, 0, 0, 1, "0", "0"},
- X /* 72*/ {U, 0, 0, 1, "1", "1"},
- X /* 73*/ {U, 0, 0, 1, "2", "2"},
- X /* 74*/ {U, 0, 0, 1, "3", "3"},
- X /* 75*/ {U, 0, 0, 1, "4", "4"},
- X /* 76*/ {U, 0, 0, 1, "5", "5"},
- X /* 77*/ {U, 0, 0, 1, "6", "6"},
- X /* 78*/ {U, 0, 0, 1, "7", "7"},
- X /* 79*/ {U, 0, 0, 1, "8", "8"},
- X /* 80*/ {U, 0, 0, 1, "9", "9"},
- X /* 81*/ {U, 0, 0, 1, "*", "*"},
- X /* 82*/ {S, 0, 0, 1, "\\055", "minus"},
- X /* 83*/ {U, 0, 0, 1, "\\256", "fi"},
- X /* 84*/ {U, 0, 0, 1, "\\257", "fl"},
- X /* 85*/ {D, 0, 0, 1, "doff", "ff"},
- X /* 86*/ {S, 0, 0, 1, "\\242", "cent sign"},
- X /* 87*/ {D, 0, 0, 1, "doFl", "ffl"},
- X /* 88*/ {D, 0, 0, 1, "doFi", "ffi"},
- X /* 89*/ {U, 0, 0, 1, "\\(", "("},
- X /* 90*/ {U, 0, 0, 1, "\\)", ")"},
- X /* 91*/ {U, 0, 0, 1, "[", "["},
- X /* 92*/ {U, 0, 0, 1, "]", "]"},
- X /* 93*/ {S, 0, 0, 1, "\\260", "degree"},
- X /* 94*/ {U, 0, 0, 1, "\\262", "dagger"},
- X /* 95*/ {U, 0, 0, 1, "=", "="},
- X /* 96*/ {S, 0, 0, 1, "\\322", "registered"},
- X /* 97*/ {U, 0, 0, 1, ":", ":"},
- X /* 98*/ {U, 0, 0, 1, "+", "+"},
- X /* 99*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /*100*/ {U, 0, 0, 1, "!", "!"},
- X /*101*/ {U, 0, -.1, 1.5, "\\267", "bullet"},
- X /*102*/ {U, 0, 0, 1, "?", "?"},
- X /*103*/ {S, 0, 0, 1, "\\242", "foot mark (minute)"},
- X /*104*/ {U, -.1, 0, 1, "|", "|"},
- X /*105*/ {U, 0, 0, 1, NOCODE, "unassigned"},
- X /*106*/ {S, 0, 0, 1, "\\323", "copyright"},
- X /*107*/ {D, 0, 0, 1, "dosq", "square"},
- X /*108*/ {U, 0, 0, 1, "$", "$"}
- X };
- X
- X struct troff2befont psSymFont[] = {
- X/* +-------------------------------- Troff character number
- X |
- X | +--------------------------- U: standard fonts
- X | | S: symbol font
- X | | D: draw macro
- X | | n: new font
- X | |
- X | | +------------------------ X-shift (scaled by point)
- X | | | Note: positive is right.
- X | | |
- X | | | +--------------------- Y-shift (scaled by point)
- X | | | | Note: positive is up.
- X | | | |
- X | | | | +------------------ Point scale factor
- X | | | | |
- X | | | | | +-------------- Sequence
- X | | | | | |
- X | | | | | | Printable sequence title
- X | | | | | | |
- X | | | | | | |
- X v v v v v v v */
- X /* 1*/ {S, 0, 0, 1, "\\171", "psi"},
- X /* 2*/ {S, 0, 0, 1, "\\161", "theta"},
- X /* 3*/ {S, 0, 0, 1, "\\156", "nu"},
- X /* 4*/ {S, 0, 0, 1, "\\155", "mu"},
- X /* 5*/ {S, 0, 0, 1, "\\154", "lambda"},
- X /* 6*/ {S, 0, 0, 1, "\\151", "iota"},
- X /* 7*/ {S, 0, 0, 1, "\\172", "zeta"},
- X /* 8*/ {S, 0, 0, 1, "\\163", "sigma"},
- X /* 9*/ {S, 0, 0, 1, "\\144", "delta"},
- X /* 10*/ {S, 0, 0, 1, "\\142", "beta"},
- X /* 11*/ {S, 0, 0, 1, "\\170", "xi"},
- X /* 12*/ {S, 0, 0, 1, "\\150", "eta"},
- X /* 13*/ {S, 0, 0, 1, "\\146", "phi"},
- X /* 14*/ {S, 0, 0, 1, "\\165", "upsilon"},
- X /* 15*/ {S, 0, 0, 1, "\\153", "kappa"},
- X /* 16*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /* 17*/ {S, 0, 0, 1, "\\160", "pi"},
- X /* 18*/ {U, 0, 0, 1, "@", "@"},
- X /* 19*/ {S, 0, 0, 1, "\\257", "down arrow"},
- X /* 20*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /* 21*/ {S, 0, 0, 1, "\\141", "alpha"},
- X /* 22*/ {S, 0, 0, 1, "\\174", "or (was star)"},
- X /* 23*/ {S, 0, 0, 1, "\\143", "chi"},
- X /* 24*/ {U, 0, 0, 1, "\\042", "double quote"},
- X /* 25*/ {S, 0, 0, 1, "\\145", "epsilon"},
- X /* 26*/ {S, 0, 0, 1, "\\075", "equation equal"},
- X /* 27*/ {S, 0, 0, 1, "\\157", "omicron"},
- X /* 28*/ {S, 0, 0, 1, "\\254", "left arrow"},
- X /* 29*/ {S, 0, 0, 1, "\\162", "rho"},
- X /* 30*/ {S, 0, 0, 1, "\\255", "up arrow"},
- X /* 31*/ {S, 0, 0, 1, "\\164", "tau"},
- X /* 32*/ {4, 0, 0, 1, "O", "underline"},
- X /* 33*/ {U, 0, 0, 1, "\\134", "\\\\"},
- X /* 34*/ {S, 0, 0, 1, "\\131", "Psi"},
- X /* 35*/ {D, 0, 0, 1, "BellSymbol", "bell system sign"},
- X /* 36*/ {S, 0, 0, 1, "\\245", "infinity"},
- X /* 37*/ {S, 0, 0, 1, "\\147", "gamma"},
- X /* 38*/ {S, 0, 0, 1, "\\312", "improper superset"},
- X /* 39*/ {S, 0, 0, 1, "\\265", "proportional to"},
- X /* 40*/ {S, 0, 0, 1, "\\336", "right hand"},
- X /* 41*/ {S, 0, 0, 1, "\\167", "omega"},
- X /* 42*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /* 43*/ {S, 0, 0, 1, "\\321", "gradient"},
- X /* 44*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /* 45*/ {S, 0, 0, 1, "\\106", "Phi"},
- X /* 46*/ {S, 0, 0, 1, "\\121", "Theta"},
- X /* 47*/ {S, 0, 0, 1, "\\127", "Omega"},
- X /* 48*/ {S, 0, 0, 1, "\\310", "union"},
- X /* 49*/ {4, 0, 0, 1, "M", "root en"},
- X /* 50*/ {S, 0, 0, 1, "\\123", "terminal sigma (was root em)"},
- X /* 51*/ {S, 0, 0, 1, "\\114", "Lambda"},
- X /* 52*/ {S, 0, 0, 1, "\\055", "equation minus"},
- X /* 53*/ {S, 0, 0, 1, "\\107", "Gamma"},
- X /* 54*/ {S, 0, 0, 1, "\\362", "integral sign"},
- X /* 55*/ {S, 0, 0, 1, "\\120", "Pi"},
- X /* 56*/ {S, 0, 0, 1, "\\314", "subset of"},
- X /* 57*/ {S, 0, 0, 1, "\\311", "superset of"},
- X /* 58*/ {U, 0, 0, 1, "\\176", "approximates"},
- X /* 59*/ {S, 0, 0, 1, "\\266", "partial derivative"},
- X /* 60*/ {S, 0, 0, 1, "\\104", "Delta"},
- X /* 61*/ {S, .35, 0, 1, "\\326", "square root"},
- X /* 62*/ {S, 0, 0, 1, "\\123", "Sigma"},
- X /* 63*/ {S, 0, 0, 1, "\\273", "approx ="},
- X /* 64*/ {S, 0, 0, 1, "\\076", ">"},
- X /* 65*/ {S, 0, 0, 1, "\\130", "Xi"},
- X /* 66*/ {S, 0, 0, 1, "\\074", "<"},
- X /* 67*/ {S, 0, 0, 1, "\\244", "long slash (longer)"},
- X /* 68*/ {S, 0, 0, 1, "\\307", "intersect"},
- X /* 69*/ {S, 0, 0, 1, "\\125", "Upsilon"},
- X /* 70*/ {S, 0, 0, 1, "\\330", "logical not"},
- X /* 71*/ {4, 0, 0, 1, "J", "right ceiling"},
- X /* 72*/ {4, 0, 0, 1, "B", "left top brace"},
- X /* 73*/ {4, 0, 0, 1, "A", "bold vertical"},
- X /* 74*/ {4, 0, 0, 1, "C", "left ctr brace"},
- X /* 75*/ {4, 0, 0, 1, "D", "left bot brace"},
- X /* 76*/ {4, 0, 0, 1, "E", "right top brace"},
- X /* 77*/ {4, 0, 0, 1, "F", "right ctr brace"},
- X /* 78*/ {4, 0, 0, 1, "G", "right bot brace"},
- X /* 79*/ {4, 0, 0, 1, "K", "right floor"},
- X /* 80*/ {4, 0, 0, 1, "I", "left floor"},
- X /* 81*/ {4, 0, 0, 1, "H", "left ceiling"},
- X /* 82*/ {S, 0, 0, 1, "\\264", "multiply"},
- X /* 83*/ {S, 0, 0, 1, "\\270", "divide"},
- X /* 84*/ {S, 0, 0, 1, "\\261", "plus-minus"},
- X /* 85*/ {S, 0, 0, 1, "\\243", "<="},
- X /* 86*/ {S, 0, 0, 1, "\\263", ">="},
- X /* 87*/ {S, 0, 0, 1, "\\272", "identically equal"},
- X /* 88*/ {S, 0, 0, 1, "\\271", "not equal"},
- X /* 89*/ {S, 0, 0, 1, "\\173", "{"},
- X /* 90*/ {S, 0, 0, 1, "\\175", "}"},
- X /* 91*/ {U, 0, 0, 1, "\\302", "acute accent"},
- X /* 92*/ {U, 0, 0, 1, "\\301", "grave accent"},
- X /* 93*/ {U, 0, 0, 1, "\\303", "^"},
- X /* 94*/ {U, 0, 0, 1, "\\043", "#"},
- X /* 95*/ {S, 0, 0, 1, "\\334", "left hand"},
- X /* 96*/ {S, 0, 0, 1, "\\316", "member of"},
- X /* 97*/ {U, 0, 0, 1, "\\304", "~"},
- X /* 98*/ {S, 0, 0, 1, "\\306", "empty set"},
- X /* 99*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /*100*/ {U, 0, 0, 1, "\\263", "dbl dagger"},
- X /*101*/ {4, 0, 0, 1, "L", "box rule (was parallel sign)"},
- X /*102*/ {S, 0, 0, 1, "\\052", "math * "},
- X /*103*/ {S, 0, 0, 1, "\\315", "improper subset"},
- X /*104*/ {4, 0, 0, 1, "N", "circle"},
- X /*105*/ {S, 0, 0, 1, NOCODE, "unassigned"},
- X /*106*/ {S, 0, 0, 1, "\\053", "equation plus"},
- X /*107*/ {S, 0, 0, 1, "\\256", "right arrow"},
- X /*108*/ {U, 0, 0, 1, "\\247", "section"}
- X};
- X
- XpsPage() {
- X EMITPS("ShowPage\n");
- X EMITPS("PageSave restore\n");
- X pagePending = 1;
- X}
- X
- Xstatic
- XdoPageStart(e) {
- X currentPage++;
- X EMITPS("%%%%Page: ? %d\n", currentPage);
- X#ifdef BIN
- X switch(Bin) {
- X case 'M':
- X EMITPS("/manualfeed true def\n");
- X break;
- X default:
- X fprintf(stderr,
- X "%s: bad bin selection %c - set to default\n", progname,
- X Bin);
- X Bin = 'D';
- X case 'D':
- X EMITPS("/manualfeed false def\n");
- X break;
- X }
- X#endif
- X#ifdef FORM
- X EMITPS("/Form { %s } def\n", Overlay);
- X#endif
- X EMITPS("/PageSave save def\n");
- X pagePending = 0;
- X EMITPS("StartPage\n");
- X}
- X
- Xstatic int lastFont = (-1), lastPoints = (-1);
- X
- XpsSetFont(font, points)
- Xint font, points; {
- X if (lastPoints != points || font != lastFont) {
- X psFts[font].flags |= USED;
- X#ifdef FONTMACRO
- X EMITPS("/%s %d SetFont\n", psFts[font].fontName, points);
- X#else
- X EMITPS("/%s dup /curFont exch def findfont\n",
- X psFts[font].fontName);
- X EMITPS("%d dup /curPoints exch def scalefont setfont\n", points);
- X#endif
- X lastPoints = points;
- X lastFont = font;
- X }
- X}
- X
- XpsChar(x, y, font, points, troffChar)
- Xint x, y, font, points, troffChar; {
- X static double lasty = (-1);
- X register double nx = TROFF2PSX(x), ny = TROFF2PSY(y);
- X register struct troff2befont *rp;
- X register char *sequence = "a";
- X if (pagePending) {
- X lasty = lastFont = lastPoints = (-1);
- X doPageStart();
- X }
- X
- X charCount++;
- X
- X DEBUGPRINTF("x,y=%d,%d; font=%d, points=%d, tc=%d\n",
- X x, y, font, points, troffChar);
- X
- X if (font == 3) {
- X rp = &be->besymfont[troffChar];
- X } else {
- X rp = &be->bestdfont[troffChar];
- X }
- X
- X switch(rp->t2b_font) {
- X /* Only fonts with "U" are subject to font translation */
- X case U:
- X if (font == 3)
- X font = 0; /* Special chars are Courier */
- X else {
- X DEBUGPRINTF("psSetChar %d->%s (%s)\n", font,
- X t2psf[font]->troffName,
- X t2psf[font]->fontName);
- X font = t2psf[font] - psFts;
- X }
- X break;
- X case S:
- X font = 3;
- X break;
- X case D:
- X break;
- X default:
- X /* Typically used when the main fonts don't have the
- X character desired. Eg: right-hand is in the
- X ZapfDingbats font */
- X font = rp->t2b_font;
- X break;
- X }
- X
- X sequence = rp->t2b_charseq;
- X
- X if (!sequence) {
- X fprintf(stderr, "No coding for %d\n", troffChar);
- X return;
- X }
- X
- X /* We're committed now */
- X
- X points *= rp->t2b_scale;
- X nx += points * rp->t2b_xc;
- X ny += points * rp->t2b_yc;
- X psSetFont(font, points);
- X if (rp->t2b_font == D)
- X EMITPS("%g %g %s\n", nx, ny, sequence);
- X else {
- X emitnum(nx);
- X if (lasty != ny) {
- X EMITPS(" ");
- X emitnum(ny);
- X EMITPS("(%s)Y\n", sequence);
- X lasty = ny;
- X } else
- X EMITPS("(%s)X\n",sequence);
- X }
- X}
- X
- Xemitnum(val)
- Xdouble val; {
- X static char buffer[30];
- X register char *p;
- X sprintf(buffer, "%g", val);
- X p = strchr(buffer, '.');
- X if (p)
- X *(p+2) = '\0';
- X EMITPS(buffer);
- X}
- X
- X
- Xstatic
- Xloadfontdefs(f)
- XFILE *f; {
- X struct psFts *p = psFts;
- X extern char *malloc();
- X char rbuf[512], nbuf[512], psbuf[512];
- X while(fgets(rbuf, sizeof(rbuf), f)) {
- X switch(sscanf(rbuf, "%s%s", nbuf, psbuf)) {
- X default:
- X break;
- X case 2:
- X if (nbuf[0] == '#')
- X break;
- X if (p - psFts >= MAXFONT) {
- X fprintf(stderr, "Too many font definitions in %s\n",
- X PSFONTS);
- X exit(1);
- X }
- X p->troffName = malloc(strlen(nbuf) + 1);
- X strcpy(p->troffName, nbuf);
- X p->fontName = malloc(strlen(psbuf) + 1);
- X strcpy(p->fontName, psbuf);
- X p++;
- X }
- X }
- X#ifdef DEBUG
- X for (p = psFts; p->troffName; p++)
- X DEBUGPRINTF("%s -> %s\n", p->troffName, p->fontName);
- X#endif
- X}
- X
- Xextern char nodename[];
- X
- XpsProlog() {
- X extern char *getlogin(), *ctime();
- X extern char *strchr();
- X char buffer[512];
- X char *lognm;
- X FILE *library;
- X int c;
- X long curtime;
- X
- X currentPage = 0;
- X pagePending = 1;
- X
- X for (c = 0; c < 8; c++)
- X t2psf[c] = &psFts[c];
- X if ((library = fopen(PSFONTS, "r")) == NULL) {
- X sprintf(buffer, "%s/%s", LIBDIR, PSFONTS);
- X if ((library = fopen(buffer, "r")) == NULL) {
- X fprintf(stderr, "Cannot open PostScript font definitions %s\n",
- X buffer);
- X exit(1);
- X }
- X }
- X
- X loadfontdefs(library);
- X fclose(library);
- X
- X if ((library = fopen(PSLIB, "r")) == NULL) {
- X sprintf(buffer, "%s/%s", LIBDIR, PSLIB);
- X if ((library = fopen(buffer, "r")) == NULL) {
- X fprintf(stderr, "Cannot open %s\n", buffer);
- X exit(1);
- X }
- X }
- X
- X time(&curtime);
- X strcpy(buffer, ctime(&curtime));
- X *strchr(buffer, '\n') = '\0';
- X getnodename();
- X
- X lognm = getlogin();
- X if (!lognm || !*lognm)
- X lognm = "unknown";
- X
- X EMITPS("%%!PS-Adobe-1.0\n");
- X EMITPS("%%%%Title: (stdin)\n");
- X EMITPS("%%%%Creator: %s %s %s\n", lognm, progname, T2VERSION);
- X EMITPS("%%%%CreationDate: %s\n", buffer);
- X EMITPS("%%%%For: %s\n", lognm);
- X EMITPS("%%%%Pages: (atend)\n");
- X EMITPS("%%%%DocumentFonts: (atend)\n");
- X EMITPS("%%%%EndComments\n");
- X EMITPS("(%s@%s %s %s %s\n) print\n", lognm, nodename, buffer,
- X progname, T2VERSION);
- X psXlate(library);
- X EMITPS("/GlobalSave save def\n");
- X EMITPS("%%%%EndProlog\n");
- X fclose(library);
- X}
- X
- XpsEpilog() {
- X int i;
- X#ifdef METRICS
- X int curpos = 720; /* ten inches from bottom of page */
- X#define XD 36
- X#define CH 16
- X if (metrics) {
- X psBin("");
- X psOverlay("");
- X doPageStart();
- X lastFont = -1; /* force the font change nomatter what */
- X psSetFont(0, 16);
- X EMITPS("%d %d(%s Execution Summary:)Y\n", progname, XD, curpos);
- X curpos -= CH;
- X EMITPS("%d %d(Font cache hits: )Y Hits show\n",
- X XD + 18, curpos);
- X curpos -= CH;
- X EMITPS("%d %d(Font cache misses: )Y Misses show\n",
- X XD + 18, curpos);
- X curpos -= CH;
- X EMITPS("%d %d(Character Count: %d)Y\n",
- X charCount, XD + 18, curpos);
- X psPage();
- X }
- X#endif
- X EMITPS("%%%%Trailer\n");
- X EMITPS("GlobalSave restore\n");
- X EMITPS("%%%%DocumentFonts:");
- X for (i = 0; i < MAXFONT; i++)
- X if (psFts[i].flags&USED)
- X EMITPS(" %s", psFts[i].fontName);
- X EMITPS("\n");
- X EMITPS("%%%%Pages: %d\n", currentPage);
- X putchar('\004');
- X}
- X
- XpsFontSel(from, to)
- Xchar from, *to; {
- X#ifdef DEBUG
- X register int i;
- X register struct psFts *p;
- X#endif
- X DEBUGPRINTF("psFontSel: %c -> %s\n", from, to);
- X if (from < '1' || from > '8') {
- X fprintf(stderr, "Bad arguments to psFontSel: %c %s\n", from, to);
- X return;
- X }
- X
- X for (p = psFts; p->troffName; p++)
- X if (strcmp(p->troffName, to) == 0) {
- X t2psf[from - '1'] = p;
- X break;
- X }
- X if (!p->troffName) {
- X fprintf(stderr, "Could not translate font %c (%s)\n", from, to);
- X }
- X#ifdef DEBUG
- X for (i = 0; i < 8; i++)
- X DEBUGPRINTF("Font %d->%s\n", i+1, t2psf[i]->fontName);
- X#endif
- X}
- X
- X/*struct troff2befont *
- XpsGetFontTables(which)
- Xint which; {
- X return(which? symbolFont: standardFont);
- X}*/
- X
- XpsXlate(library)
- XFILE *library; {
- X char buf[512];
- X while (fgets(buf, sizeof(buf), library))
- X if (0 == strncmp(buf, "%%%", 3))
- X interp(&buf[3], psXlate, ".ps");
- X else
- X fputs(buf, stdout);
- X}
- X
- XpsOverlay(overlay)
- Xchar *overlay; {
- X#ifdef FORM
- X strcpy(Overlay, overlay);
- X EMITPS("%%%%%%Form set: %s\n", Overlay);
- X#endif
- X}
- X
- XpsBin(bin)
- Xchar *bin; {
- X#ifdef BIN
- X Bin = *bin;
- X#endif
- X}
- X
- X#endif /* PS */
- END_OF_FILE
- if test 19066 -ne `wc -c <'ps.c'`; then
- echo shar: \"'ps.c'\" unpacked with wrong size!
- fi
- # end of 'ps.c'
- fi
- echo shar: End of archive 5 \(of 6\).
- cp /dev/null ark5isdone
- MISSING=""
- for I in 1 2 3 4 5 6 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 6 archives.
- echo "Read README to install psroff"
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-